import { queryOperation, list, deleteByIds, clear } from '@/api/operLogger'

const getDefaultState = () => {
  return {
  }
}

const state = getDefaultState()

const mutations = {

}

const actions = {
  /**
   * 查询操作
   */
  getOperation() {
    return new Promise(function (resolve, reject) {
      queryOperation().then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  },
  /**
   * 查询操作日志列表
   */
  list({ commit }, searParams) {
    return new Promise(function (resolve, reject) {
      list(searParams).then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  },
  /**
   * 通过id删除操作日志
   */
  removeByIds({ commit }, logIds) {
    return new Promise(function (resolve, reject) {
      deleteByIds(logIds).then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  },
  /**
   * 清空日志
   */
  clear() {
    return new Promise(function (resolve, reject) {
      clear().then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
